package com.dd.shop4j.sys.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dd.shop4j.sys.service.SysConstantService;
import com.dd.shop4j.sys.service.AddressService.AddressInfo;

@Controller
@RequestMapping("/constant")
public class SysConstantController {

	@Resource
	private SysConstantService sysConstantService;
	
	@ResponseBody
	@RequestMapping("/clear")
	public void clear() {
		sysConstantService.clear();
	}
	
	@ResponseBody
	@RequestMapping("/provinces")
	public List<AddressInfo> provinces() {
		return sysConstantService.getProvinces();
	}
	
	@ResponseBody
	@RequestMapping("/citys/{provinceId}")
	public List<AddressInfo> citys(@PathVariable("provinceId") Integer provinceId) {
		return sysConstantService.getCitysByProvinceId(provinceId);
	}
	
	@ResponseBody
	@RequestMapping("/districts/{cityId}")
	public List<AddressInfo> districts(@PathVariable("cityId") Integer cityId) {
		return sysConstantService.getDistrictsByCityId(cityId);
	}
}
